package demo;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

//Day08
public class Day18002 {
    public static void main(String[] args) {
        HashMap<Integer,String> map=new HashMap<>();
        map.put(101,"阿三面馆");
        map.put(102,"阿四粥馆");
        map.put(103,"阿五米馆");
//        验证put方法具有返回值
        System.out.println(map.put(104,"阿六快递"));
        System.out.println(map.put(101,"adbd"));
//        输出，以k--v形式输出
        for (Integer key:
             map.keySet()) {
            String value=map.get(key);
            System.out.print(key+"--"+value+" ");
        }
        System.out.println();
        map.forEach((key,value)->{
            System.out.print(key+"--"+value+" ");
        });

        System.out.println();
        Set<Map.Entry<Integer, String>> entries = map.entrySet();
        for (Map.Entry<Integer, String> entry : entries) {
            System.out.print(entry.getKey() + "---" + entry.getValue()+" ");
        }
    }
}
